<template>
  <div :class="[$style.container]">
    <common-header :class="[$style.header]"></common-header>
    <div :class="[$style.body]">
      <div :class="[$style.loginBox]">
        <code-login v-if="type === 'phone'" :type.sync="type"></code-login>
        <account-login v-else-if="type === 'username'" :type.sync="type"></account-login>
        <account-registry v-else-if="type === 'registry'" :type.sync="type"></account-registry>
        <dingtalk-login v-else-if="type === 'ding_talk'" :type.sync="type"></dingtalk-login>
        <wecom-login v-else-if="type === 'wecom'" :type.sync="type"></wecom-login>
      </div>
    </div>
    <div :class="[$style.footer]">
    </div>
  </div>

</template>

<script lang="ts">
import { Component, Prop, Provide, Ref, Vue, Watch } from 'vue-property-decorator'
import CommonHeader from './components/common-header/index.vue'
import CodeLogin from './components/code-login/index.vue'
import AccountLogin from './components/account-login/index.vue'
import AccountRegistry from './components/account-registry/index.vue'
import DingtalkLogin from './components/dingtalk-login/index.vue'
import WecomLogin from './components/wecom-login/index.vue'
import { AppModule } from '@/store'

@Component({
  components: { CommonHeader, CodeLogin, AccountLogin, AccountRegistry, DingtalkLogin, WecomLogin }
})
export default class Login extends Vue {
  @Ref() dingtalkLogin!: DingtalkLogin

  @Ref() wecomLogin!: WecomLogin

  @AppModule.State properties!: any

  type: 'phone' | 'username' | 'ding_talk' | 'wecom' = 'username'

  // get defaultType () {
  //   return this.properties?.deploy?.defaultLoginType || 'username'
  // }

  @Provide() otherLogin (type: string) {
    this.type = type as any
  }

  // @Watch('defaultType', { immediate: true }) defaultTypeChange () {
  //   this.type = this.defaultType
  // }
}
</script>

<style lang="scss" module>
@import "~@/styles/vars.scss";

.container {
  background-color: $bg-body-color;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  flex: 0 0 auto;
}

.body {
  flex: 1 1 auto;
}

.loginBox {
  background-color: $bg-color;
  padding: 32px 32px;
  border-radius: 4px;
  border: 1px solid $border-color;
  box-shadow: 0px 0px 6px rgb(0 0 0 / 10%);
  width: 360px;
  margin: 10vh auto auto auto;
}

.footer {
  flex: 0 0 auto;
  font-size: 12px;
  color: $text-secondary-color;
  text-align: center;
  margin: 48px 0;
}

</style>
